package com.example.demo.controller;

import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/user")
@RestController
public class UserController {
    @RequestMapping("/login")
    public String login(String userName, String password) {
        //1. 校验参数
        if (!StringUtils.hasLength(userName) || !StringUtils.hasLength(password)) {
            return "用户名或密码为空！";
        }
        //2. 验证密码是否正确
        //先模拟校验
        //3. 如果正确，返回相应结果
        if("admin".equals(userName) && "admin".equals(password)) {
            return "";
        }
        return "密码错误";

    }
}
